package cjq.demo.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cjq.demo.push.PushBean;
import cjq.demo.push.PushUtils;


public class APNServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String username = req.getParameter("username");
		String msg = req.getParameter("message");
		String title = req.getParameter("title");
		PushBean pb = new PushBean();
		pb.setMessage(msg);
		pb.setUri("");
		pb.setUsername(username);
		pb.setTitle(title);
		try {
//			Thread.sleep(10000);
			PushUtils.sendSingle(pb);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}

}
